package com.situ.mymall.service.impl;

import com.situ.mymall.mapper.MallAreaMapper;
import com.situ.mymall.mapper.MallCityMapper;
import com.situ.mymall.mapper.MallProvinceMapper;
import com.situ.mymall.mapper.UserMapper;
import com.situ.mymall.pojo.entity.MallProvince;
import com.situ.mymall.pojo.entity.User;
import com.situ.mymall.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private MallProvinceMapper mallProvinceMapper;

    @Autowired
    private MallCityMapper mallCityMapper;

    @Autowired
    private MallAreaMapper mallAreaMapper;

    @Override
    public User login(String name, String password) {
        return userMapper.login(name,password);
    }

    @Override
    public void add(User user) {
        userMapper.insertSelective(user);
    }

    @Override
    public List<MallProvince> selectByProvince() {
        return mallProvinceMapper.selectByProvince();
    }

    @Override
    public List<MallProvince> selectByCity(Long provinceId) {
        return mallCityMapper.selectByCity(provinceId);
    }

    @Override
    public List<MallProvince> selectByArea(Integer cityId) {
        return mallAreaMapper.selectByArea(cityId);
    }
}
